<template>
  <form @submit="formSubmit">
    <div class='depotEnterDetail'>
      <scroll-view scroll-y>
        <detailList type='到店高管审核'></detailList>
        <div class="detailList">
            <div class="weui-cells__title header">高管审核</div>
          <div class="weui-cells weui-cells_after-title">
            <div class="weui-cell">
              <div class="weui-cell__bd">高管审核</div>
              <div class="weui-cell__ft">
                <radio-group @change="radioChange"  name="xinxi">
                  <label class="weui-check__label" v-for="(item,index) in data.radio" :key="index">
                     <radio class="weui-check" :disabled="editCode" :value="item.value"  />
                    <div class="weui-cell__hd weui-check__hd_in-checkbox">
                      <icon class="weui-icon-checkbox_circle" type="circle" size="23" v-if="!item.checked"></icon>
                      <icon class="weui-icon-checkbox_success" type="success" size="23" v-if="item.checked"></icon>
                    </div>
                    <div class="weui-cell__bd">{{item.name}}</div>
                  </label>
                </radio-group>
              </div>
            </div>

             <div class="weui-cell">
              <div class="weui-cell__bd">确认备注</div>
              <div class="weui-cell__ft">
                <input maxlength="100" :disabled="editCode"  name="beizhu" :value="data.beizhu" placeholder="填写备注" />
              </div>
            </div>

          </div>
        </div>
        <view class="btn-area submit">
          <button formType="submit">提交</button>
        </view>
      </scroll-view>
    </div>
  </form>
</template>

<script>
  import Qinniu from '@/components/common/Qinniu'
  import searchTriangle from "@/components/common/searchTriangle"
  import detailList from '@/components/common/detailList'
  export default {
    data() {
      return {
        data:{
          xinxi:"",
          beizhu:"",
          radio:"",
        },
        editCode: true, //编辑，还会查看，亦或者是添加
      }
    },
    methods: {
      is_disabled() {
        let code = this.$mp.query.idCode
        switch (true) {
          case code == 1: //编辑
            this.editCode = false;
            break;
          case code == 2: //查看
            this.editCode = true;
            break;
          default:
            this.editCode = false;
            break; //添加
        }
      },
      initValidate() {
        // 验证字段的规则
        const rules = {
          xinxi: {
            required: true
          },

        }

        const message = {
          xinxi: {
            required: "请选择确认信息"
          },
        }
        //创建实例对象
        this.WxValidate = new this.wxValidate(rules, message);
      },
      formSubmit: function (e) {
        const params = e.mp.detail.value
        // 传入表单数据，调用验证方法
        if (!this.WxValidate.checkForm(params)) {
          const error = this.WxValidate.errorList[0]
          this.WxValidate.showModal(error)
          return false
        }
        this.$https.post("http://rap2api.taobao.org/app/mock/22254/lyl/xiaochegnxu/Warehousing_button_post", {params,}).then(res => {
            this.WxValidate.showModal({
              msg: '提交成功',
            })
        })
      },
       radioChange(e) {
            console.log('radio 携带的值为：' + e.mp.detail.value);
            let value = e.mp.detail.value;
            let radio = this.data.radio;
          for (let i = 0; i < radio.length; ++i) {
            radio[i].checked = radio[i].value ===value;
          }
          this.radio = radio;

            //单选验证需要手动赋值
            this.data.xinxi =value ;
         
      }
    },
     mounted() {
      this.initValidate();
      this.is_disabled();
      this.$https.get("http://rap2api.taobao.org/app/mock/22254/lyl/xiaochengxu/WarehousingDetail", {
        id: this.$mp.query.id
      }).then(res => {
          this.data = Object.assign({},this.data,res.data.data);
      })
    },
    components: {
      Qinniu,searchTriangle,detailList
    }
  }
</script>


<style lang="scss" scoped>
  .depotEnterDetail {
    height: 100%;
    box-sizing: border-box;
    scroll-view {
      height: 100%;
    
    }

  
    
  }
</style>
